// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "GameFramework/Info.h"
#include "System/GameplayTagStack.h"

#include "LyraTeamInfoBase.generated.h"

namespace EEndPlayReason { enum Type : int; }

class ULyraTeamCreationComponent;
class ULyraTeamSubsystem;
class UObject;
struct FFrame;

UCLASS(Abstract)
class ALyraTeamInfoBase : public AInfo
{
	GENERATED_BODY()

public:
	ALyraTeamInfoBase(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); // 构造函数

	int32 GetTeamId() const { return TeamId; } // 获取团队ID

	//~AActor接口
	virtual void BeginPlay() override; // 开始播放
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; // 结束播放
	//~AActor接口结束

protected:
	/**
	 * 注册到团队子系统
	 */
	virtual void RegisterWithTeamSubsystem(ULyraTeamSubsystem* Subsystem);

	/**
	 * 尝试注册到团队子系统
	 */
	void TryRegisterWithTeamSubsystem();

private:
	/**
	 * 设置团队ID
	 */
	void SetTeamId(int32 NewTeamId);

	/**
	 * 当团队ID复制时调用
	 */
	UFUNCTION()
	void OnRep_TeamId();

public:
	friend ULyraTeamCreationComponent; // 友元类

	UPROPERTY(Replicated)
	FGameplayTagStackContainer TeamTags; // 团队标签栈容器

private:
	UPROPERTY(ReplicatedUsing=OnRep_TeamId)
	int32 TeamId; // 团队ID
};